<?php
/**
 * Created by PhpStorm.
 * User: liu
 * Date: 2018/5/16
 * Time: 15:43
 */

namespace app\common\except;


use Exception;
use think\Container;
use think\exception\Handle;
use think\exception\HttpResponseException;
use think\facade\Log;
use think\Response;

class ExceptHandler extends Handle
{
    public function render(Exception $e)
    {
        if($e instanceof Common){
            //记录common
            Log::write($e->getTraceAsString(),'debug');
            $response = Response::create($e->getMessage(), 'html')->options(['jump_template' => Container::get('config')->get('dispatch_success_tmpl')]);
            $e=new HttpResponseException($response);
        }
        return parent::render($e); // TODO: Change the autogenerated stub
    }
}